package org.cable.link.strategy;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 * @author hsj
 * @date 2023/10/30 15:30
 */
public class ShardingTableConfig {


    /**
     * 存储表位置编号
     */
    public static final List<String> tablePrefixList = new ArrayList<>();


    //配置启用哪些库的前缀
    static {
        tablePrefixList.add("0");
        tablePrefixList.add("a");
    }

    private static Random random = new Random();

    /** 随机 0 | a*/
    public static String getRandomDbPrefix(String code) {
        int hashCode = code.hashCode();
        int index =  Math.abs(hashCode) % tablePrefixList.size();
        return tablePrefixList.get(index);
    }
}
